home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Include / intobject.h < prev    next >
C/C++ Source or Header  |  1997-08-02  |  3KB  |  92 lines

  1. #ifndef Py_INTOBJECT_H
  2. #define Py_INTOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  9. The Netherlands.
  10.  
  11.                         All Rights Reserved
  12.  
  13. Permission to use, copy, modify, and distribute this software and its
  14. documentation for any purpose and without fee is hereby granted,
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in
  17. supporting documentation, and that the names of Stichting Mathematisch
  18. Centrum or CWI or Corporation for National Research Initiatives or
  19. CNRI not be used in advertising or publicity pertaining to
  20. distribution of the software without specific, written prior
  21. permission.
  22.  
  23. While CWI is the initial source for this software, a modified version
  24. is made available by the Corporation for National Research Initiatives
  25. (CNRI) at the Internet address ftp://ftp.python.org.
  26.  
  27. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  28. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  29. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  30. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  31. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  32. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  33. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34. PERFORMANCE OF THIS SOFTWARE.
  35.  
  36. ******************************************************************/
  37.  
  38. /* Integer object interface */
  39.  
  40. /*
  41. 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
  42.  
  43. PyIntObject represents a (long) integer.  This is an immutable object;
  44. an integer cannot change its value after creation.
  45.  
  46. There are functions to create new integer objects, to test an object
  47. for integer-ness, and to get the integer value.  The latter functions
  48. returns -1 and sets errno to EBADF if the object is not an PyIntObject.
  49. None of the functions should be applied to nil objects.
  50.  
  51. The type PyIntObject is (unfortunately) exposed here so we can declare
  52. _Py_TrueStruct and _Py_ZeroStruct below; don't use this.
  53. */
  54.  
  55. typedef struct {
  56.     PyObject_HEAD
  57.     long ob_ival;
  58. } PyIntObject;
  59.  
  60. extern DL_IMPORT(PyTypeObject) PyInt_Type;
  61.  
  62. #define PyInt_Check(op) ((op)->ob_type == &PyInt_Type)
  63.  
  64. extern PyObject *PyInt_FromLong Py_PROTO((long));
  65. extern long PyInt_AsLong Py_PROTO((PyObject *));
  66. extern long PyInt_GetMax Py_PROTO((void));
  67.  
  68.  
  69. /*
  70. 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
  71.  
  72. False and True are special intobjects used by Boolean expressions.
  73. All values of type Boolean must point to either of these; but in
  74. contexts where integers are required they are integers (valued 0 and 1).
  75. Hope these macros don't conflict with other people's.
  76.  
  77. Don't forget to apply Py_INCREF() when returning True or False!!!
  78. */
  79.  
  80. extern DL_IMPORT(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; /* Don't use these directly */
  81.  
  82. #define Py_False ((PyObject *) &_Py_ZeroStruct)
  83. #define Py_True ((PyObject *) &_Py_TrueStruct)
  84.  
  85. /* Macro, trading safety for speed */
  86. #define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
  87.  
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif /* !Py_INTOBJECT_H */
  92.